this.BX=this.BX||{};(function(e,t,i,n,s,a){"use strict";var r,o,l,u,d,c,h,m,p,f;var g=function(){function e(t){babelHelpers.classCallCheck(this,e);babelHelpers.defineProperty(this,"isProgress",false);s.EventEmitter.makeObservable(this,"UI.Timeline.Item");this.id=t.id;this.createdTimestamp=null;this.action="";this.title="";this.description="";this.htmlDescription="";this.textDescription="";this.userId=t.userId;this.isFixed=t.isFixed===true;this.data={};this.eventIds=new Set;if(a.Type.isPlainObject(t)){if(a.Type.isSet(t.eventIds)){this.eventIds=t.eventIds}if(a.Type.isString(t.action)){this.action=t.action}if(a.Type.isString(t.title)){this.title=t.title}if(a.Type.isString(t.description)){this.description=t.description}if(a.Type.isString(t.htmlDescription)){this.htmlDescription=t.htmlDescription}if(a.Type.isString(t.textDescription)){this.textDescription=t.textDescription}if(a.Type.isNumber(t.createdTimestamp)){this.createdTimestamp=t.createdTimestamp}if(a.Type.isPlainObject(t.data)){this.data=t.data}}this.layout={};this.timeFormat="H:M";this.nameFormat="";this.users=new Map;this.isLast=false;this.events=t.events;this.isPinned=false}babelHelpers.createClass(e,[{key:"afterRender",value:function e(){a.Event.bind(this.renderPin(),"click",this.onPinClick.bind(this));this.bindActionsButtonClick()}},{key:"bindActionsButtonClick",value:function e(){var t=this.getActionsButton();if(t){a.Event.bind(t,"click",this.onActionsButtonClick.bind(this))}}},{key:"setIsLast",value:function e(t){this.isLast=t;if(this.isRendered()){if(this.isLast){this.getContainer().classList.add("ui-item-detail-stream-section-last")}else{this.getContainer().classList.remove("ui-item-detail-stream-section-last")}}}},{key:"setUserData",value:function e(t){if(t){this.users=t}return this}},{key:"setTimeFormat",value:function e(t){if(a.Type.isString(t)){this.timeFormat=t}return this}},{key:"setNameFormat",value:function e(t){if(a.Type.isString(t)){this.nameFormat=t}return this}},{key:"getContainer",value:function e(){return this.layout.container}},{key:"isRendered",value:function e(){return a.Type.isDomNode(this.getContainer())}},{key:"getCreatedTime",value:function e(){if(this.createdTimestamp>0){this.createdTimestamp=a.Text.toInteger(this.createdTimestamp);return new Date(this.createdTimestamp)}return null}},{key:"formatTime",value:function e(t){return BX.date.format(this.timeFormat,t)}},{key:"getId",value:function e(){return this.id}},{key:"getTitle",value:function e(){return this.title}},{key:"getUserId",value:function e(){return a.Text.toInteger(this.userId)}},{key:"getScope",value:function e(){if(a.Type.isString(this.data.scope)){return this.data.scope}return null}},{key:"isScopeManual",value:function e(){var t=this.getScope();return!t||t==="manual"}},{key:"isScopeAutomation",value:function e(){return this.getScope()==="automation"}},{key:"isScopeTask",value:function e(){return this.getScope()==="task"}},{key:"isScopeRest",value:function e(){return this.getScope()==="rest"}},{key:"render",value:function e(){this.layout.container=this.renderContainer();this.updateLayout();return this.layout.container}},{key:"updateLayout",value:function e(){this.clearLayout(true);this.layout.container.appendChild(this.renderIcon());if(this.hasMenu()){this.layout.container.appendChild(this.renderActionsButton())}this.layout.container.appendChild(this.renderPin());var t=this.getContent();if(!t){t=this.renderContent()}this.layout.container.appendChild(t);this.afterRender()}},{key:"renderContainer",value:function e(){return a.Tag.render(r||(r=babelHelpers.taggedTemplateLiteral(['<div class="ui-item-detail-stream-section ','"></div>'])),this.isLast?"ui-item-detail-stream-section-last":"")}},{key:"renderPin",value:function e(){if(!this.layout.pin){this.layout.pin=a.Tag.render(o||(o=babelHelpers.taggedTemplateLiteral(['<span class="ui-item-detail-stream-section-top-fixed-btn"></span>'])))}if(this.isFixed){this.layout.pin.classList.add("ui-item-detail-stream-section-top-fixed-btn-active")}else{this.layout.pin.classList.remove("ui-item-detail-stream-section-top-fixed-btn-active")}return this.layout.pin}},{key:"renderContent",value:function e(){this.layout.content=a.Tag.render(l||(l=babelHelpers.taggedTemplateLiteral(['<div class="ui-item-detail-stream-section-content">',"</div>"])),this.renderDescription());return this.getContent()}},{key:"getContent",value:function e(){return this.layout.content}},{key:"renderDescription",value:function e(){this.layout.description=a.Tag.render(u||(u=babelHelpers.taggedTemplateLiteral(['<div class="ui-item-detail-stream-content-event"></div>'])));var t=this.renderHeader();if(t){this.layout.description.appendChild(t)}this.layout.description.appendChild(this.renderMain());return this.layout.description}},{key:"renderHeader",value:function e(){return null}},{key:"renderHeaderUser",value:function e(t){t=a.Text.toInteger(t);var i={link:"javascript: void(0)",fullName:"",photo:null};if(t>0){i=this.users.get(t)}if(!i){return a.Tag.render(d||(d=babelHelpers.taggedTemplateLiteral(["<a></a>"])))}var n=a.Tag.safe(c||(c=babelHelpers.taggedTemplateLiteral(["",""])),i.fullName);return a.Tag.render(h||(h=babelHelpers.taggedTemplateLiteral(['<a class="ui-item-detail-stream-content-employee" href="','" target="_blank" title="','" ',"></a>"])),i.link,n,i.photo?"style=\"background-image: url('"+i.photo+"'); background-size: 100%;\"":"")}},{key:"renderMain",value:function e(){this.layout.main=a.Tag.render(m||(m=babelHelpers.taggedTemplateLiteral(['<div class="ui-item-detail-stream-content-detail">',"</div>"])),this.description);return this.getMain()}},{key:"getMain",value:function e(){return this.layout.main}},{key:"renderIcon",value:function e(){this.layout.icon=a.Tag.render(p||(p=babelHelpers.taggedTemplateLiteral(['<div class="ui-item-detail-stream-section-icon"></div>'])));return this.layout.icon}},{key:"getItem",value:function e(){if(a.Type.isPlainObject(this.data.item)){return this.data.item}return null}},{key:"onPinClick",value:function e(){this.isFixed=!this.isFixed;this.renderPin();if(a.Type.isFunction(this.events.onPinClick)){this.events.onPinClick(this)}this.emit("onPinClick")}},{key:"clearLayout",value:function e(){var t=this;var i=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;var n=this.getContainer();Object.keys(this.layout).forEach((function(e){var s=t.layout[e];if(!i||n!==s){a.Dom.remove(s);delete t.layout[e]}}));return this}},{key:"getDataForUpdate",value:function e(){return{description:this.description,htmlDescription:this.htmlDescription,data:this.data,userId:this.userId}}},{key:"updateData",value:function e(t){if(a.Type.isPlainObject(t)){if(a.Type.isString(t.description)){this.description=t.description}if(a.Type.isString(t.htmlDescription)){this.htmlDescription=t.htmlDescription}if(a.Type.isPlainObject(t.data)){this.data=t.data}if(t.userId>0){this.userId=t.userId}}return this}},{key:"update",value:function e(t){this.updateData(t).updateLayout();return this}},{key:"onError",value:function e(t){if(a.Type.isFunction(this.events.onError)){this.events.onError(t)}this.emit("error",t)}},{key:"onDelete",value:function e(){if(a.Type.isFunction(this.events.onDelete)){this.events.onDelete(this)}this.emit("onDeleteComplete")}},{key:"hasMenu",value:function e(){return this.hasActions()}},{key:"hasActions",value:function e(){return this.getActions().length>0}},{key:"getActions",value:function e(){return[]}},{key:"renderActionsButton",value:function e(){this.layout.contextMenuButton=a.Tag.render(f||(f=babelHelpers.taggedTemplateLiteral(['<div class="ui-timeline-item-context-menu"></div>'])));return this.getActionsButton()}},{key:"getActionsButton",value:function e(){return this.layout.contextMenuButton}},{key:"getActionsMenuId",value:function e(){return"ui-timeline-item-context-menu-"+this.getId()}},{key:"onActionsButtonClick",value:function e(){this.getActionsMenu().toggle()}},{key:"getActionsMenu",value:function e(){return n.MenuManager.create({id:this.getActionsMenuId(),bindElement:this.getActionsButton(),items:this.getActions(),offsetTop:0,offsetLeft:16,angle:{position:"top",offset:0},events:{onPopupShow:this.onContextMenuShow.bind(this),onPopupClose:this.onContextMenuClose.bind(this)}})}},{key:"onContextMenuShow",value:function e(){this.getActionsButton().classList.add("active")}},{key:"onContextMenuClose",value:function e(){this.getActionsButton().classList.remove("active");this.getActionsMenu().destroy()}},{key:"startProgress",value:function e(){this.isProgress=true;this.getLoader().show()}},{key:"stopProgress",value:function e(){this.isProgress=false;if(this.getLoader().isShown()){this.getLoader().hide()}}},{key:"getLoader",value:function e(){if(!this.loader){this.loader=new t.Loader({target:this.getContainer()})}return this.loader}}]);return e}();var v,y,b,T,k,C;var I=function(e){babelHelpers.inherits(t,e);function t(){babelHelpers.classCallCheck(this,t);return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).apply(this,arguments))}babelHelpers.createClass(t,[{key:"renderContainer",value:function e(){var i=babelHelpers.get(babelHelpers.getPrototypeOf(t.prototype),"renderContainer",this).call(this);if(this.isScopeAutomation()){i.classList.add("ui-item-detail-stream-section-icon-robot")}else{i.classList.add("ui-item-detail-stream-section-info")}return i}},{key:"renderHeader",value:function e(){return a.Tag.render(v||(v=babelHelpers.taggedTemplateLiteral(['<div class="ui-item-detail-stream-content-header">\n\t\t\t<div class="ui-item-detail-stream-content-title">\n\t\t\t\t<span class="ui-item-detail-stream-content-title-text">','</span>\n\t\t\t\t<span class="ui-item-detail-stream-content-title-time">',"</span>\n\t\t\t</div>\n\t\t\t","\n\t\t</div>"])),a.Text.encode(this.getTitle()),this.formatTime(this.getCreatedTime()),this.renderHeaderUser(this.getUserId()))}},{key:"renderStageChangeTitle",value:function e(){return a.Tag.render(y||(y=babelHelpers.taggedTemplateLiteral(['<div class="ui-item-detail-stream-content-title">\n\t\t\t<span class="ui-item-detail-stream-content-title-text">',"</span>\n\t\t</div>"])),a.Loc.getMessage("UI_TIMELINE_STAGE_CHANGE_SUBTITLE"))}},{key:"renderStageChange",value:function e(){var t=this.getStageFrom();var i=this.getStageTo();if(t&&i&&t.id!==i.id){return a.Tag.render(b||(b=babelHelpers.taggedTemplateLiteral(['<div class="ui-item-detail-stream-content-detail-info">\n\t\t\t\t<span class="ui-item-detail-stream-content-detail-info-status">','</span>\n\t\t\t\t<span class="ui-item-detail-stream-content-detail-info-separator"></span>\n\t\t\t\t<span class="ui-item-detail-stream-content-detail-info-status">',"</span>\n\t\t\t</div>"])),a.Text.encode(t.name),a.Text.encode(i.name))}return null}},{key:"getStageFrom",value:function e(){if(a.Type.isPlainObject(this.data.stageFrom)){return this.data.stageFrom}return null}},{key:"getStageTo",value:function e(){if(a.Type.isPlainObject(this.data.stageTo)){return this.data.stageTo}return null}},{key:"getFields",value:function e(){if(a.Type.isArray(this.data.fields)){return this.data.fields}return null}},{key:"renderFieldsChange",value:function e(){var t=this.getFields();if(t){var i=[];t.forEach((function(e){i.push(a.Tag.render(T||(T=babelHelpers.taggedTemplateLiteral(['<div class="ui-item-detail-stream-content-detail-field">',"</div>"])),a.Text.encode(e.title)))}));return a.Tag.render(k||(k=babelHelpers.taggedTemplateLiteral(['<div class="ui-item-detail-stream-content-detail-info ui-item-detail-stream-content-detail-info-break">\n\t\t\t\t',"\n\t\t\t</div>"])),i)}return null}},{key:"renderFieldsChangeTitle",value:function e(){return a.Tag.render(C||(C=babelHelpers.taggedTemplateLiteral(['<div class="ui-item-detail-stream-content-title">\n\t\t\t<span class="ui-item-detail-stream-content-title-text">',"</span>\n\t\t</div>"])),a.Loc.getMessage("UI_TIMELINE_FIELDS_CHANGE_SUBTITLE"))}}]);return t}(g);var E;var D=function(e){babelHelpers.inherits(t,e);function t(){babelHelpers.classCallCheck(this,t);return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).apply(this,arguments))}babelHelpers.createClass(t,[{key:"renderMain",value:function e(){var t=this.renderStageChange();if(!t){t=""}var i=this.renderFieldsChange();if(!i){i=""}return a.Tag.render(E||(E=babelHelpers.taggedTemplateLiteral(['<div class="ui-item-detail-stream-content-detail">\n\t\t\t',"\n\t\t\t","\n\t\t</div>"])),t,i)}}]);return t}(I);var P;var L=function(e){babelHelpers.inherits(t,e);function t(){babelHelpers.classCallCheck(this,t);return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).apply(this,arguments))}babelHelpers.createClass(t,[{key:"renderMain",value:function e(){var t=this.renderFieldsChange();if(!t){t=""}return a.Tag.render(P||(P=babelHelpers.taggedTemplateLiteral(['<div class="ui-item-detail-stream-content-detail">\n\t\t\t',"\n\t\t</div>"])),t)}}]);return t}(I);var H=function(){function e(t){babelHelpers.classCallCheck(this,e);babelHelpers.defineProperty(this,"isProgress",false);if(a.Type.isString(t.id)&&t.id.length>0){this.id=t.id}else{this.id=a.Text.getRandom()}this.layout={};s.EventEmitter.makeObservable(this,"BX.UI.Timeline.Editor")}babelHelpers.createClass(e,[{key:"getId",value:function e(){return this.id}},{key:"getTitle",value:function e(){}},{key:"getContainer",value:function e(){return this.layout.container}},{key:"render",value:function e(){throw new Error("This method should be overridden")}},{key:"clearLayout",value:function e(){var t=this;var i=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;var n=this.getContainer();Object.keys(this.layout).forEach((function(e){var s=t.layout[e];if(!i||n!==s){a.Dom.clean(s);delete t.layout[e]}}));return this}},{key:"startProgress",value:function e(){this.isProgress=true;this.getLoader().show()}},{key:"stopProgress",value:function e(){this.isProgress=false;if(this.getLoader().isShown()){this.getLoader().hide()}}},{key:"getLoader",value:function e(){if(!this.loader){this.loader=new t.Loader({target:this.getContainer()})}return this.loader}},{key:"isRendered",value:function e(){return a.Type.isDomNode(this.getContainer())}}]);return e}();var x,F,A,M,B,w,S;var O=function(e){babelHelpers.inherits(t,e);function t(e){var i;babelHelpers.classCallCheck(this,t);i=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this,e));babelHelpers.defineProperty(babelHelpers.assertThisInitialized(i),"commentId",0);babelHelpers.defineProperty(babelHelpers.assertThisInitialized(i),"editorContent",null);if(a.Type.isNumber(e.commentId)){i.commentId=e.commentId}i.setEventNamespace("BX.UI.Timeline.CommentEditor");return i}babelHelpers.createClass(t,[{key:"getTitle",value:function e(){return a.Loc.getMessage("UI_TIMELINE_EDITOR_COMMENT")}},{key:"getVisualEditorName",value:function e(){return"UiTimelineCommentVisualEditor"+this.getId().replace("- ","")}},{key:"getTextarea",value:function e(){return this.layout.textarea}},{key:"renderTextarea",value:function e(){this.layout.textarea=a.Tag.render(x||(x=babelHelpers.taggedTemplateLiteral(['<textarea onfocus="','" rows="1" class="ui-item-detail-stream-section-new-comment-textarea" placeholder="','"></textarea>'])),this.onFocus.bind(this),a.Loc.getMessage("UI_TIMELINE_EDITOR_COMMENT_TEXTAREA"));return this.getTextarea()}},{key:"getVisualEditorContainer",value:function e(){return this.layout.visualEditorContainer}},{key:"renderVisualEditorContainer",value:function e(){this.layout.visualEditorContainer=a.Tag.render(F||(F=babelHelpers.taggedTemplateLiteral(['<div class="ui-timeline-comment-visual-editor"></div>'])));return this.getVisualEditorContainer()}},{key:"getButtonsContainer",value:function e(){return this.layout.buttonsContainer}},{key:"renderButtons",value:function e(){this.layout.buttonsContainer=a.Tag.render(A||(A=babelHelpers.taggedTemplateLiteral(['<div class="ui-item-detail-stream-section-new-comment-btn-container">\n\t\t\t',"\n\t\t\t","\n\t\t</div>"])),this.renderSaveButton(),this.renderCancelButton());return this.getButtonsContainer()}},{key:"getSaveButton",value:function e(){return this.layout.saveButton}},{key:"renderSaveButton",value:function e(){this.layout.saveButton=a.Tag.render(M||(M=babelHelpers.taggedTemplateLiteral(['<button onclick="','" class="ui-btn ui-btn-xs ui-btn-primary">',"</button>"])),this.save.bind(this),a.Loc.getMessage("UI_TIMELINE_EDITOR_COMMENT_SEND"));return this.getSaveButton()}},{key:"getCancelButton",value:function e(){return this.layout.cancelButton}},{key:"renderCancelButton",value:function e(){this.layout.cancelButton=a.Tag.render(B||(B=babelHelpers.taggedTemplateLiteral(['<span onclick="','" class="ui-btn ui-btn-xs ui-btn-link">',"</span>"])),this.cancel.bind(this),a.Loc.getMessage("UI_TIMELINE_EDITOR_COMMENT_CANCEL"));return this.getCancelButton()}},{key:"render",value:function e(){this.layout.container=a.Tag.render(w||(w=babelHelpers.taggedTemplateLiteral(['<div class="ui-timeline-comment-editor">\n\t\t\t\t',"\n\t\t\t\t","\n\t\t\t\t","\n\t\t\t</div>"])),this.renderTextarea(),this.renderButtons(),this.renderVisualEditorContainer());return this.getContainer()}},{key:"onFocus",value:function e(){var t=this.getContainer();if(t){t.classList.add("focus")}this.showVisualEditor()}},{key:"showVisualEditor",value:function e(){var t=this;if(!this.getVisualEditorContainer()){return}if(this.postForm&&this.visualEditor){this.postForm.eventNode.style.display="block";this.visualEditor.Focus()}else if(!this.isProgress){this.loadVisualEditor().then((function(){s.EventEmitter.emit(t.postForm.eventNode,"OnShowLHE",[true]);setTimeout((function(){t.editorContent=t.postForm.oEditor.GetContent()}),300)}))["catch"]((function(){t.cancel();t.emit("error",{message:"Could not load visual editor. Please try again later"})}))}}},{key:"loadVisualEditor",value:function e(){var t=this;return new Promise((function(e,i){if(t.isProgress){i()}t.showEditorLoader();var n=new s.BaseEvent({data:{name:t.getVisualEditorName(),commentId:t.commentId}});t.emitAsync("onLoadVisualEditor",n).then((function(){var s=n.getData().html;if(a.Type.isString(s)){a.Runtime.html(t.getVisualEditorContainer(),s).then((function(){t.hideEditorLoader();if(LHEPostForm&&BXHtmlEditor){t.postForm=LHEPostForm.getHandler(t.getVisualEditorName());t.visualEditor=BXHtmlEditor.Get(t.getVisualEditorName());e()}else{i()}}))}else{i()}}))["catch"]((function(){i()}))}))}},{key:"showEditorLoader",value:function e(){this.editorLoader=a.Tag.render(S||(S=babelHelpers.taggedTemplateLiteral(['<div class="ui-timeline-wait"></div>'])));a.Dom.append(this.editorLoader,this.getContainer())}},{key:"hideEditorLoader",value:function e(){a.Dom.remove(this.editorLoader)}},{key:"hideVisualEditor",value:function e(){if(this.postForm){this.postForm.eventNode.style.display="none"}}},{key:"save",value:function e(){var t=this;if(this.isProgress||!this.postForm){return}var i=false;var n=this.postForm.oEditor.GetContent();this.editorContent=n;var a=this.getAttachments();this.emit("beforeSave",{description:n,isCancel:i,files:a});if(n===""){this.getEmptyMessageNotification().show();return}this.startProgress();var r=new s.BaseEvent({data:{description:n,files:a,commentId:this.commentId}});this.emitAsync("onSave",r).then((function(){t.postForm.reinit();t.stopProgress();t.emit("afterSave",{data:r.getData()});t.cancel()}))["catch"]((function(){t.stopProgress();t.cancel();var e=r.getData().message;if(e){t.emit("error",{message:e})}}))}},{key:"cancel",value:function e(){this.hideVisualEditor();var t=this.getContainer();if(t){t.classList.remove("focus")}this.stopProgress();this.emit("cancel")}},{key:"getEmptyMessageNotification",value:function e(){if(!this.emptyMessagePopup){this.emptyMessagePopup=new n.Popup({id:this.getId()+"-empty-message-popup",bindElement:this.getSaveButton(),content:BX.message("UI_TIMELINE_EMPTY_COMMENT_NOTIFICATION"),darkMode:true,autoHide:true,zIndex:990,angle:{position:"top",offset:77},closeByEsc:true,bindOptions:{forceBindPosition:true}})}return this.emptyMessagePopup}},{key:"refresh",value:function e(){if(this.postForm&&this.postForm.oEditor){if(this.editorContent){this.postForm.oEditor.SetContent(this.editorContent)}}if(this.visualEditor){this.visualEditor.ReInitIframe()}}},{key:"getAttachments",value:function e(){var t=this;var i=[];if(!this.postForm||!a.Type.isPlainObject(this.postForm.arFiles)||!a.Type.isPlainObject(this.postForm.controllers)){return i}var n=[];Object.values(this.postForm.arFiles).forEach((function(e){if(!n.includes(e)){n.push(e)}}));n.forEach((function(e){if(t.postForm.controllers[e]&&a.Type.isPlainObject(t.postForm.controllers[e].values)){Object.keys(t.postForm.controllers[e].values).forEach((function(e){if(!i.includes(e)){i.push(e)}}))}}));return i}}]);return t}(H);var N,_,R,U,X,j;var V=128;var z=function(e){babelHelpers.inherits(t,e);function t(e){var i;babelHelpers.classCallCheck(this,t);i=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this,e));babelHelpers.defineProperty(babelHelpers.assertThisInitialized(i),"isCollapsed",null);babelHelpers.defineProperty(babelHelpers.assertThisInitialized(i),"isContentLoaded",null);i.setEventNamespace("BX.UI.Timeline.Comment");return i}babelHelpers.createClass(t,[{key:"afterRender",value:function e(){var i=this;babelHelpers.get(babelHelpers.getPrototypeOf(t.prototype),"afterRender",this).call(this);if(this.isCollapsed===null){this.isCollapsed=this.isAddExpandBlock()}if(this.isContentLoaded===null){this.isContentLoaded=!this.hasFiles()}if(this.isCollapsed){this.getMain().classList.add("ui-timeline-content-description-collapsed");this.getMain().classList.remove("ui-timeline-content-description-expand")}else{this.getMain().classList.remove("ui-timeline-content-description-collapsed");this.getMain().classList.add("ui-timeline-content-description-expand")}if(this.isAddExpandBlock()){this.getMainDescription().appendChild(this.renderExpandBlock())}if(this.hasFiles()){this.getContent().appendChild(a.Tag.render(N||(N=babelHelpers.taggedTemplateLiteral(['<div class="ui-timeline-section-files">',"</div>"])),this.renderFilesContainer()));a.Event.ready((function(){setTimeout((function(){i.loadFilesContent()}),100)}))}}},{key:"getFiles",value:function e(){if(a.Type.isArray(this.data.files)){return this.data.files}return[]}},{key:"hasFiles",value:function e(){return this.getFiles().length>0}},{key:"isAddExpandBlock",value:function e(){return this.textDescription.length>V||this.hasFiles()}},{key:"renderContainer",value:function e(){var i=babelHelpers.get(babelHelpers.getPrototypeOf(t.prototype),"renderContainer",this).call(this);i.classList.add("ui-item-detail-stream-section-comment");i.classList.remove("ui-item-detail-stream-section-info");return i}},{key:"renderMain",value:function e(){this.layout.main=a.Tag.render(_||(_=babelHelpers.taggedTemplateLiteral(['<div class="ui-item-detail-stream-content-detail">\n\t\t\t',"\n\t\t</div>"])),this.renderMainDescription());return this.getMain()}},{key:"getMain",value:function e(){return this.layout.main}},{key:"renderMainDescription",value:function e(){this.layout.mainDescription=a.Tag.render(R||(R=babelHelpers.taggedTemplateLiteral(['<div class="ui-item-detail-stream-content-description" onclick="','">',"</div>"])),this.onMainClick.bind(this),this.htmlDescription);return this.getMainDescription()}},{key:"getMainDescription",value:function e(){return this.layout.mainDescription}},{key:"renderExpandBlock",value:function e(){this.layout.expandBlock=a.Tag.render(U||(U=babelHelpers.taggedTemplateLiteral(['<div class="ui-timeline-content-description-expand-container">',"</div>"])),this.renderExpandButton());return this.getExpandBlock()}},{key:"getExpandBlock",value:function e(){return this.layout.expandBlock}},{key:"renderExpandButton",value:function e(){this.layout.expandButton=a.Tag.render(X||(X=babelHelpers.taggedTemplateLiteral(['<a class="ui-timeline-content-description-expand-btn" onclick="','">\n\t\t\t',"\n\t\t</a>"])),this.onExpandButtonClick.bind(this),a.Loc.getMessage(this.isCollapsed?"UI_TIMELINE_EXPAND_SM":"UI_TIMELINE_COLLAPSE_SM"));return this.getExpandButton()}},{key:"getExpandButton",value:function e(){return this.layout.expandButton}},{key:"getCommendEditor",value:function e(){if(!this.commentEditor){this.commentEditor=new O({commentId:this.getId(),id:"UICommentEditor"+this.getId()+(this.isPinned?"pinned":"")+a.Text.getRandom()});this.commentEditor.layout.container=this.getContainer();this.commentEditor.subscribe("cancel",this.switchToViewMode.bind(this));this.commentEditor.subscribe("afterSave",this.onSaveComment.bind(this))}return this.commentEditor}},{key:"getEditorContainer",value:function e(){return this.layout.editorContainer}},{key:"renderEditorContainer",value:function e(){var t=this.getCommendEditor().getVisualEditorContainer();if(t){this.layout.editorContainer=t}else{this.layout.editorContainer=this.getCommendEditor().renderVisualEditorContainer()}return this.getEditorContainer()}},{key:"getEditorButtons",value:function e(){return this.layout.editorButtons}},{key:"renderEditorButtons",value:function e(){this.layout.editorButtons=this.getCommendEditor().renderButtons();return this.getEditorButtons()}},{key:"renderFilesContainer",value:function e(){this.layout.filesContainer=a.Tag.render(j||(j=babelHelpers.taggedTemplateLiteral(['<div class="ui-timeline-section-files-inner"></div>'])));return this.getFilesContainer()}},{key:"getFilesContainer",value:function e(){return this.layout.filesContainer}},{key:"switchToEditMode",value:function e(){if(!this.isRendered()){return}if(!this.getEditorContainer()){this.getMain().appendChild(this.renderEditorContainer());this.getMain().appendChild(this.renderEditorButtons())}else{this.getCommendEditor().refresh()}this.getContent().classList.add("ui-item-detail-comment-edit");this.getCommendEditor().showVisualEditor()}},{key:"switchToViewMode",value:function e(){this.getContent().classList.remove("ui-item-detail-comment-edit");this.getCommendEditor().hideVisualEditor()}},{key:"getActions",value:function e(){return[{text:a.Loc.getMessage("UI_TIMELINE_ACTION_MODIFY"),onclick:this.actionEdit.bind(this)},{text:a.Loc.getMessage("UI_TIMELINE_ACTION_DELETE"),onclick:this.actionDelete.bind(this)}]}},{key:"actionEdit",value:function e(){this.getActionsMenu().close();this.switchToEditMode()}},{key:"actionDelete",value:function e(){var t=this;this.getActionsMenu().close();i.MessageBox.confirm(a.Loc.getMessage("UI_TIMELINE_COMMENT_DELETE_CONFIRM"),(function(){return new Promise((function(e){if(t.isProgress){return}t.startProgress();var i=new s.BaseEvent({data:{commentId:t.getId()}});t.emitAsync("onDelete",i).then((function(){t.stopProgress();t.onDelete();e()}))["catch"]((function(){t.stopProgress();var n=i.getData().message;if(n){t.emit("error",{message:n})}e()}))}))}))}},{key:"clearLayout",value:function e(){var i=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;this.commentEditor=null;return babelHelpers.get(babelHelpers.getPrototypeOf(t.prototype),"clearLayout",this).call(this,i)}},{key:"onSaveComment",value:function e(t){var i=t.getData();if(i.data&&i.data.comment){this.update(i.data.comment)}}},{key:"onMainClick",value:function e(t){var i=t.target;if(a.Type.isDomNode(i)){var n=i.tagName.toLowerCase();if(n==="a"||n==="img"||a.Dom.hasClass(i,"feed-con-file-changes-link-more")||a.Dom.hasClass(i,"feed-com-file-inline")||document.getSelection().toString().length>0){return}}this.switchToEditMode()}},{key:"onExpandButtonClick",value:function e(t){var i=this;t.preventDefault();t.stopPropagation();if(!this.isRendered()){return}if(this.isCollapsed===true){this.getExpandBlock().style.maxHeight=this.getExpandBlock().scrollHeight+130+"px";this.getMain().classList.remove("ui-timeline-content-description-collapsed");this.getMain().classList.add("ui-timeline-content-description-expand");setTimeout((function(){i.getExpandBlock().style.maxHeight=""}),300);this.getExpandButton().innerText=a.Loc.getMessage("UI_TIMELINE_COLLAPSE_SM");if(!this.isContentLoaded){this.isContentLoaded=true;this.loadContent()}this.isCollapsed=false}else if(this.isCollapsed===false){this.getExpandBlock().style.maxHeight=this.getExpandBlock().scrollHeight+"px";this.getMain().classList.add("ui-timeline-content-description-collapsed");this.getMain().classList.remove("ui-timeline-content-description-expand");setTimeout((function(){i.getExpandBlock().style.maxHeight=""}),0);this.getExpandButton().innerText=a.Loc.getMessage("UI_TIMELINE_EXPAND_SM");this.isCollapsed=true}}},{key:"loadFilesContent",value:function e(){var t=this;if(this.isProgress){return}this.startProgress();var i=new s.BaseEvent({data:{commentId:this.getId()}});this.emitAsync("onLoadFilesContent",i).then((function(){t.stopProgress();var e=i.getData().html;if(a.Type.isString(e)){a.Runtime.html(t.getFilesContainer(),e)}}))["catch"]((function(){t.stopProgress();var e=i.getData().message;if(e){t.emit("error",{message:e})}}))}},{key:"loadContent",value:function e(){var t=this;if(this.isProgress){return}this.startProgress();var i=new s.BaseEvent({data:{commentId:this.getId()}});this.emitAsync("onLoadContent",i).then((function(){t.stopProgress();var e=i.getData().comment;if(e&&a.Type.isString(e.htmlDescription)){a.Runtime.html(t.getMainDescription(),e.htmlDescription);if(t.isAddExpandBlock()){t.getMainDescription().appendChild(t.getExpandBlock())}t.updateData(e)}}))["catch"]((function(){t.stopProgress();var e=i.getData().message;if(e){t.emit("error",{message:e})}}))}}]);return t}(I);var G=function(){function e(){babelHelpers.classCallCheck(this,e)}babelHelpers.createClass(e,[{key:"start",value:function e(){}},{key:"finish",value:function e(t,i){}}]);return e}();var q;var Y=function(e){babelHelpers.inherits(t,e);function t(e){var i;babelHelpers.classCallCheck(this,t);i=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this,e));if(a.Type.isPlainObject(e)){if(e.item instanceof g&&a.Type.isDomNode(e.container)){i.item=e.item;i.container=e.container;i.insertAfter=e.insertAfter}}return i}babelHelpers.createClass(t,[{key:"start",value:function e(){var i=this;var n=t.DEFAULT_TIMEOUT;return new Promise((function(e){if(!i.item||!i.container){e()}setTimeout((function(){i.createGhost(i.item.render(),e)}),n)}))}},{key:"createGhost",value:function e(t,i){t.style.position="absolute";t.style.width=this.container.offsetWidth+"px";t.style.top=a.Dom.getPosition(this.container).top+"px";t.style.left=a.Dom.getPosition(this.container).left+"px";document.body.appendChild(t);this.anchor=a.Tag.render(q||(q=babelHelpers.taggedTemplateLiteral(['<div class="ui-item-detail-stream-section ui-item-detail-stream-section-shadow"></div>'])));a.Dom.prepend(this.anchor,this.container);if(a.Type.isDomNode(this.insertAfter)){a.Dom.insertAfter(this.anchor,this.insertAfter)}this.moveGhost(t,i)}},{key:"moveGhost",value:function e(i,n){var s=this;var r=a.Dom.getPosition(this.anchor);var o=a.Dom.getPosition(this.container);var l=new BX.easing({duration:t.DURATION,start:{top:o.top,height:0},finish:{top:r.top-5,height:a.Dom.getPosition(i).height},transition:BX.easing.makeEaseOut(BX.easing.transitions.quart),step:function e(t){i.style.top=t.top+"px";s.anchor.style.height=t.height+"px"},complete:function e(){s.finish(i,n)}});l.animate()}},{key:"finish",value:function e(t,i){t.style.position="";t.style.width="";t.style.height="";t.style.top="";t.style.left="";t.style.opacity="";a.Dom.insertAfter(t,this.anchor);a.Dom.remove(this.anchor);this.anchor=null;if(a.Type.isFunction(i)){i()}}}]);return t}(G);babelHelpers.defineProperty(Y,"DEFAULT_TIMEOUT",150);babelHelpers.defineProperty(Y,"DURATION",1200);var W=function(e){babelHelpers.inherits(t,e);function t(e){var i;babelHelpers.classCallCheck(this,t);i=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this,e));if(a.Type.isPlainObject(e)){if(e.item instanceof g&&a.Type.isDomNode(e.anchor)){i.item=e.item;i.anchor=e.anchor;i.startPosition=e.startPosition}}return i}babelHelpers.createClass(t,[{key:"start",value:function e(){var i=this;return new Promise((function(e){if(!i.item||!i.anchor){e()}i.node=i.item.render();a.Dom.addClass(i.node,"ui-item-detail-stream-section-top-fixed");i.node.style.position="absolute";i.node.style.width=i.startPosition.width+"px";var n=i.startPosition.height;var s=65;var r=18;if(n<r+s)n=r+s;i.node.style.height=n+"px";i.node.style.top=i.startPosition.top+"px";i.node.style.left=i.startPosition.left+"px";i.node.style.zIndex=960;document.body.appendChild(i.node);i._anchorPosition=a.Dom.getPosition(i.anchor);var o={top:i._anchorPosition.top,height:n+15,opacity:1};var l=i.startPosition.top-i._anchorPosition.bottom;var u=2*(document.body.clientHeight+i.startPosition.height);if(l>u){o.top=i.startPosition.top-u;o.opacity=0}var d=Math.abs(o.top-i.startPosition.top)*2;d=d<t.DURATION?t.DURATION:d;var c=new BX.easing({duration:d,start:{top:i.startPosition.top,height:0,opacity:1},finish:o,transition:BX.easing.makeEaseOut(BX.easing.transitions.quart),step:function e(t){i.node.style.top=t.top+"px";i.node.style.opacity=t.opacity;i.anchor.style.height=t.height+"px"},complete:function t(){i.finish(i.node,e)}});c.animate()}))}},{key:"finish",value:function e(t,i){t.style.position="";t.style.width="";t.style.height="";t.style.top="";t.style.left="";t.style.zIndex="";this.anchor.style.height=0;a.Dom.insertAfter(t,this.anchor);if(a.Type.isFunction(i)){i()}}}]);return t}(G);babelHelpers.defineProperty(W,"DURATION",1500);var K=function(e){babelHelpers.inherits(t,e);function t(e){var i;babelHelpers.classCallCheck(this,t);i=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this,e));if(a.Type.isPlainObject(e)){if(e.item instanceof g&&a.Type.isDomNode(e.container)&&a.Type.isDomNode(e.insertAfter)){i.item=e.item;i.container=e.container;i.insertAfter=e.insertAfter}}return i}babelHelpers.createClass(t,[{key:"start",value:function e(){var t=this;return new Promise((function(e){if(!t.item||!t.container||!t.insertAfter){e()}a.Dom.insertAfter(t.item.render(),t.insertAfter);t.expand().then((function(){t.fadeIn().then((function(){t.finish(t.item.getContainer(),e)}))}))}))}},{key:"expand",value:function e(){var i=this;return new Promise((function(e){var n=i.item.getContainer();var s=a.Dom.getPosition(n);n.style.height=0;n.style.opacity=0;n.style.overflow="hidden";var r=new BX.easing({duration:t.EXPAND_DURATION,start:{height:0},finish:{height:s.height},transition:BX.easing.makeEaseOut(BX.easing.transitions.quart),step:function e(t){n.style.height=t.height+"px"},complete:e});r.animate()}))}},{key:"fadeIn",value:function e(){var i=this;return new Promise((function(e){i.item.getContainer().style.overflow="";var n=new BX.easing({duration:t.FADE_IN_DURATION,start:{opacity:0},finish:{opacity:100},transition:BX.easing.makeEaseOut(BX.easing.transitions.quart),step:function e(t){i.item.getContainer().style.opacity=t.opacity/100},complete:e});n.animate()}))}},{key:"finish",value:function e(t,i){this.item.getContainer().style.height="";this.item.getContainer().style.opacity="";if(a.Type.isFunction(i)){i()}}}]);return t}(G);babelHelpers.defineProperty(K,"EXPAND_DURATION",150);babelHelpers.defineProperty(K,"FADE_IN_DURATION",150);var J;var Q=function(e){babelHelpers.inherits(t,e);function t(e){var i;babelHelpers.classCallCheck(this,t);i=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this,e));if(a.Type.isPlainObject(e)){if(e.item instanceof g&&e.task instanceof g&&a.Type.isDomNode(e.insertAfter)){i.item=e.item;i.task=e.task;i.insertAfter=e.insertAfter}}return i}babelHelpers.createClass(t,[{key:"start",value:function e(){var t=this;return new Promise((function(e){if(!t.item||!t.task||!t.container||!t.insertAfter){e()}var i=t.item.render();var n=t.task.getContainer();var s=a.Dom.getPosition(n);i.style.position="absolute";i.style.width=n.offsetWidth+"px";i.style.top=s.top+"px";i.style.left=s.left+"px";i.style.zIndex="999";a.Dom.addClass(i,"ui-item-detail-stream-section-show");document.body.appendChild(i);t.anchor=a.Tag.render(J||(J=babelHelpers.taggedTemplateLiteral(['<div class="ui-item-detail-stream-section ui-item-detail-stream-section-shadow"></div>'])));a.Dom.prepend(t.anchor,t.container);if(a.Type.isDomNode(t.insertAfter)){a.Dom.insertAfter(t.anchor,t.insertAfter)}n.style.height=n.offsetHeight+"px";a.Dom.addClass(n,"ui-item-detail-stream-section-hide");setTimeout(function(){var t=this;var s=n.offsetHeight;this.anchor.style.height=s+"px";a.Dom.remove(n);a.Dom.removeClass(i,"ui-item-detail-stream-section-show");var r=new BX.easing({duration:800,start:{top:a.Dom.getPosition(i).top,height:s},finish:{top:a.Dom.getPosition(this.anchor).top,height:a.Dom.getPosition(i).height},transition:BX.easing.makeEaseOut(BX.easing.transitions.quart),step:function e(n){i.style.top=n.top+"px";t.anchor.style.height=n.height+"px"},complete:function n(){t.finish(i,e)}});r.animate()}.bind(t),200)}))}},{key:"finish",value:function e(t,i){t.style.position="";t.style.width="";t.style.top="";t.style.left="";t.style.zIndex="";a.Dom.insertAfter(t,this.anchor);a.Dom.remove(this.anchor);this.anchor=null;if(a.Type.isFunction(i)){i()}}}]);return t}(G);babelHelpers.defineProperty(Q,"DURATION",1200);var Z=function(e){babelHelpers.inherits(t,e);function t(e){var i;babelHelpers.classCallCheck(this,t);i=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this,e));if(a.Type.isPlainObject(e)){if(a.Type.isDomNode(e.node)){i.node=e.node}}return i}babelHelpers.createClass(t,[{key:"start",value:function e(){var i=this;return new Promise((function(e){if(!i.node){e()}var n=i.node;var s=a.Dom.getPosition(n);var r=new BX.easing({duration:t.DURATION,start:{height:s.height,opacity:1,marginBottom:15},finish:{height:0,opacity:0,marginBottom:0},transition:BX.easing.makeEaseOut(BX.easing.transitions.quart),step:function e(t){if(n){n.style.height=t.height+"px";n.style.opacity=t.opacity;n.style.marginBottom=t.marginBottom}},complete:function t(){i.finish(n,e)}});r.animate()}))}},{key:"finish",value:function e(t,i){a.Dom.remove(t);if(a.Type.isFunction(i)){i()}}}]);return t}(G);babelHelpers.defineProperty(Z,"DURATION",1e3);function $(e,t,i,n){ne(e,t);ie(i,"set");ee(e,i,n);return n}function ee(e,t,i){if(t.set){t.set.call(e,i)}else{if(!t.writable){throw new TypeError("attempted to set read only private field")}t.value=i}}function te(e,t,i){ne(e,t);ie(i,"get");return se(e,i)}function ie(e,t){if(e===undefined){throw new TypeError("attempted to "+t+" private static field before its declaration")}}function ne(e,t){if(e!==t){throw new TypeError("Private static access of wrong provenance")}}function se(e,t){if(t.get){return t.get.call(e)}return t.value}var ae=function(){function e(){babelHelpers.classCallCheck(this,e)}babelHelpers.createClass(e,null,[{key:"add",value:function t(i){te(e,e,re).push(i);return e}},{key:"run",value:function t(){if(te(e,e,oe)){return}var i=te(e,e,re).shift();if(!i){return}if(!a.Type.isArray(i)){i=[i]}$(e,e,oe,true);var n=[];i.forEach((function(e){if(e instanceof G){n.push(e.start())}}));Promise.all(n).then((function(){$(e,e,oe,false);e.run()}))}}]);return e}();var re={writable:true,value:[]};var oe={writable:true,value:false};var le,ue,de,ce,he,me,pe,fe,ge,ve,ye,be;var Te=function(){function e(t){var i=this;babelHelpers.classCallCheck(this,e);this.users=new Map;this.eventIds=new Set;this.pinnedItems=[];this.tasks=[];this.items=[];this.editors=new Map;this.layout={};this.dateSeparators=new Map;this.nameFormat=t.nameFormat;s.EventEmitter.makeObservable(this,"BX.UI.Timeline.Stream");this.initItemClasses(t.itemClasses);this.currentPage=1;if(a.Type.isPlainObject(t)){if(a.Type.isNumber(t.pageSize)){this.pageSize=t.pageSize}if(!this.pageSize||this.pageSize<=0){this.pageSize=20}this.addUsers(t.users);if(a.Type.isArray(t.items)){t.items.forEach((function(e){var t=i.createItem(e);if(t){i.addItem(t)}}))}if(a.Type.isArray(t.tasks)){this.initTasks(t.tasks)}if(a.Type.isArray(t.editors)){t.editors.forEach((function(e){if(e instanceof H){i.editors.set(e.getId(),e)}}))}}this.bindEvents();this.progress=false;this.emit("onAfterInit",{stream:this})}babelHelpers.createClass(e,[{key:"initTasks",value:function e(t){var i=this;this.tasks=[];t.forEach((function(e){var t=i.createItem(e);if(t){i.tasks.push(t)}}))}},{key:"bindEvents",value:function e(){var t=this;this.onScrollHandler=a.Runtime.throttle(this.onScroll.bind(this),100).bind(this);a.Event.ready((function(){if(t.getItems().length>=t.pageSize){t.enableLoadOnScroll()}}));Array.from(this.editors.values()).forEach((function(e){e.subscribe("error",(function(e){t.onError(e.getData())}))}))}},{key:"initItemClasses",value:function e(t){if(t){this.itemClasses=new Map(t)}else{this.itemClasses=new Map}this.itemClasses.set("item_create",I);this.itemClasses.set("stage_change",D);this.itemClasses.set("fields_change",L);this.itemClasses.set("comment",z)}},{key:"createItem",value:function e(t,i){if(!a.Type.isPlainObject(t.events)){t.events={}}t.eventIds=this.eventIds;t.events.onPinClick=this.onItemPinClick.bind(this);t.events.onDelete=this.onItemDelete.bind(this);t.events.onError=this.onError.bind(this);if(!a.Type.isFunction(i)){i=this.getItemClassName(t)}var n=new i(t);if(n instanceof g){return n.setUserData(this.users).setTimeFormat(this.getTimeFormat()).setNameFormat(this.nameFormat)}return null}},{key:"addItem",value:function e(t){if(t instanceof g){this.items.push(t);if(t.isFixed){this.pinnedItems.push(this.getPinnedItemFromItem(t))}}return this}},{key:"getItems",value:function e(){return this.items}},{key:"getItem",value:function t(i){return e.getItemFromArray(this.getItems(),i)}},{key:"getPinnedItems",value:function e(){return this.pinnedItems}},{key:"getPinnedItem",value:function t(i){return e.getItemFromArray(this.getPinnedItems(),i)}},{key:"getTasks",value:function e(){return this.tasks}},{key:"getTask",value:function t(i){return e.getItemFromArray(this.getTasks(),i)}},{key:"render",value:function e(){if(!this.layout.container){this.layout.container=a.Tag.render(le||(le=babelHelpers.taggedTemplateLiteral(['<div class="ui-item-detail-stream-container"></div>'])))}if(this.editors.size>0){this.renderEditors()}if(!this.layout.content){this.layout.content=a.Tag.render(ue||(ue=babelHelpers.taggedTemplateLiteral(['<div class="ui-item-detail-stream-content"></div>'])));this.layout.container.appendChild(this.layout.content)}if(!this.layout.pinnedItemsContainer){this.layout.pinnedItemsContainer=a.Tag.render(de||(de=babelHelpers.taggedTemplateLiteral(['<div class="ui-item-detail-stream-container-list ui-item-detail-stream-container-list-fixed"></div>'])));this.layout.content.appendChild(this.layout.pinnedItemsContainer)}this.renderPinnedItems();if(!this.layout.tasksContainer){this.layout.tasksContainer=a.Tag.render(ce||(ce=babelHelpers.taggedTemplateLiteral(['<div class="ui-item-detail-stream-container-list"></div>'])));this.layout.content.appendChild(this.layout.tasksContainer)}this.renderTasks();if(!this.layout.itemsContainer){this.layout.itemsContainer=a.Tag.render(he||(he=babelHelpers.taggedTemplateLiteral(['<div class="ui-item-detail-stream-container-list"></div>'])));this.layout.content.appendChild(this.layout.itemsContainer)}this.renderItems();this.emit("onAfterRender");return this.layout.container}},{key:"getContainer",value:function e(){return this.layout.container}},{key:"renderEditors",value:function e(){var t=this;if(!this.layout.container){return}if(!this.layout.editors){this.layout.editorsTitle=a.Tag.render(me||(me=babelHelpers.taggedTemplateLiteral(['<div class="ui-item-detail-stream-section-new-header"></div>'])));this.layout.editorsContent=a.Tag.render(pe||(pe=babelHelpers.taggedTemplateLiteral(['<div class="ui-item-detail-stream-section-new-detail"></div>'])));this.layout.editors=a.Tag.render(fe||(fe=babelHelpers.taggedTemplateLiteral(['<div class="ui-item-detail-stream-section ui-item-detail-stream-section-new">\n\t\t\t\t<div class="ui-item-detail-stream-section-icon"></div>\n\t\t\t\t<div class="ui-item-detail-stream-section-content">\n\t\t\t\t\t',"\n\t\t\t\t</div>\n\t\t\t\t","\n\t\t\t</div>"])),this.layout.editorsTitle,this.layout.editorsContent);var i=true;Array.from(this.editors.values()).forEach((function(e){t.layout.editorsTitle.appendChild(a.Tag.render(ge||(ge=babelHelpers.taggedTemplateLiteral(['<a class="ui-item-detail-stream-section-new-action ','">',"</a>"])),i?"ui-item-detail-stream-section-new-action-active":"",e.getTitle()));t.layout.editorsContent.appendChild(e.render());i=false}));this.layout.container.appendChild(this.layout.editors)}}},{key:"renderPinnedItems",value:function e(){var t=this;a.Dom.clean(this.layout.pinnedItemsContainer);this.createFixedAnchor();this.getPinnedItems().forEach((function(e){if(!e.isRendered()){e.render()}a.Dom.append(e.getContainer(),t.layout.pinnedItemsContainer)}))}},{key:"createFixedAnchor",value:function e(){this.fixedAnchor=a.Tag.render(ve||(ve=babelHelpers.taggedTemplateLiteral(['<div class="ui-item-detail-stream-section-fixed-anchor"></div>'])));a.Dom.prepend(this.fixedAnchor,this.layout.pinnedItemsContainer)}},{key:"updateTasks",value:function t(i){var n=this;if(!this.tasks){this.tasks=[]}var s=[];i.forEach((function(e){var t=n.createItem(e);if(t){s.push(t);n.addUsers(e.users)}}));var r=[];this.tasks.forEach((function(t){if(!e.getItemFromArray(s,t.getId())){r.push(t)}}));r.forEach((function(e){n.deleteItem(e)}));var o=this.getTasksTitle();if(s.length>0){if(!o){o=this.renderTasksTitle();this.layout.tasksContainer.appendChild(o)}s.forEach((function(e){if(!n.getTask(e.getId())){n.tasks.push(e);ae.add(new K({item:e,container:n.layout.tasksContainer,insertAfter:o}))}else{var t=n.getTask(e.getId());t.setUserData(n.users);t.update(e.getDataForUpdate())}}))}else{var l=this.getTasksTitle();if(l){a.Dom.remove(l);this.layout.tasksTitle=null}}ae.run()}},{key:"renderTasks",value:function e(){var t=this;if(this.getTasks().length>0){this.layout.tasksContainer.appendChild(this.renderTasksTitle());this.getTasks().forEach((function(e){if(!e.isRendered()){a.Dom.append(e.render(),t.layout.tasksContainer)}}))}else{var i=this.getTasksTitle();if(i){i.parentElement.removeChild(i)}}}},{key:"getTasksTitle",value:function e(){return this.layout.tasksTitle}},{key:"renderTasksTitle",value:function e(){if(!this.layout.tasksTitle){this.layout.tasksTitle=a.Tag.render(ye||(ye=babelHelpers.taggedTemplateLiteral(['<div class="ui-item-detail-stream-section ui-item-detail-stream-section-planned-label">\n\t\t\t\t<div class="ui-item-detail-stream-section-content">\n\t\t\t\t\t<div class="ui-item-detail-stream-planned-text">',"</div>\n\t\t\t\t</div>\n\t\t\t</div>"])),a.Loc.getMessage("UI_TIMELINE_TASKS_TITLE"))}return this.layout.tasksTitle}},{key:"renderItems",value:function e(){var t=this;var i=this.items[this.items.length-1];this.items.forEach((function(e){e.setIsLast(e===i);if(!e.isRendered()){var n=t.constructor.getDayFromDate(e.getCreatedTime());if(!t.getDateSeparator(n)){var s=t.createDateSeparator(n);a.Dom.append(s,t.layout.itemsContainer)}a.Dom.append(e.render(),t.layout.itemsContainer)}}))}},{key:"getDateSeparator",value:function e(t){return this.dateSeparators.get(t)}},{key:"createDateSeparator",value:function e(t){var i=this.renderDateSeparator(t);this.dateSeparators.set(t,i);return i}},{key:"renderDateSeparator",value:function e(t){return a.Tag.render(be||(be=babelHelpers.taggedTemplateLiteral(['<div class="ui-item-detail-stream-section ui-item-detail-stream-section-history-label">\n\t\t\t<div class="ui-item-detail-stream-section-content">\n\t\t\t\t<div class="ui-item-detail-stream-history-text">',"</div>\n\t\t\t</div>\n\t\t</div>"])),t)}},{key:"getItemClassName",value:function e(t){var i=null;if(a.Type.isPlainObject(t)&&a.Type.isString(t.itemClassName)){i=t.itemClassName}if(i){i=a.Reflection.getClass(i)}if(!a.Type.isFunction(i)){if(a.Type.isPlainObject(t)&&a.Type.isString(t.action)){i=this.itemClasses.get(t.action)}if(!i){i=I}}return i}},{key:"insertItem",value:function e(t){if(!(t instanceof g)){return this}if(this.getItem(t.getId())){return this}this.items.unshift(t);var i=this.constructor.getDayFromDate(t.getCreatedTime());if(!i){return this}if(!this.getDateSeparator(i)){var n=this.createDateSeparator(i);a.Dom.prepend(n,this.layout.itemsContainer)}ae.add(new Y({item:t,insertAfter:this.getDateSeparator(i),container:this.layout.editorsContent})).run();return this}},{key:"getTimeFormat",value:function e(){if(!this.timeFormat){var t=a.Loc.getMessage("FORMAT_DATETIME").replace(/:SS/,"");var i=a.Loc.getMessage("FORMAT_DATE");this.timeFormat=BX.date.convertBitrixFormat(t.trim().replace(i,""))}return this.timeFormat}},{key:"getDateTimeFormat",value:function e(){if(!this.dateTimeFormat){var t=a.Loc.getMessage("FORMAT_DATETIME").replace(/:SS/,"");this.dateTimeFormat=BX.date.convertBitrixFormat(t)}return this.dateTimeFormat}},{key:"startProgress",value:function e(){this.progress=true;if(!this.getLoader().isShown()){var t=this.items[this.items.length-1];if(t&&t.isRendered()){this.getLoader().show(t.getContainer())}else{this.getLoader().show(this.layout.container)}}}},{key:"stopProgress",value:function e(){this.progress=false;this.getLoader().hide()}},{key:"isProgress",value:function e(){return this.progress===true}},{key:"getLoader",value:function e(){if(!this.loader){this.loader=new t.Loader({size:150})}return this.loader}},{key:"enableLoadOnScroll",value:function e(){a.Event.bind(window,"scroll",this.onScrollHandler)}},{key:"disableLoadOnScroll",value:function e(){a.Event.unbind(window,"scroll",this.onScrollHandler)}},{key:"onScroll",value:function e(){if(this.isProgress()){return}var t=this.items[this.items.length-1];if(!t){this.disableLoadOnScroll();return}if(!t.isRendered()){return}var i=t.getContainer().getBoundingClientRect();if(i.top<=document.documentElement.clientHeight){this.emit("onScrollToTheBottom")}}},{key:"getPinnedItemFromItem",value:function e(t){var i=a.Runtime.clone(t);if(t.isRendered()){i.clearLayout()}i.setTimeFormat(this.getDateTimeFormat());i.isPinned=true;return i}},{key:"onItemPinClick",value:function e(t){if(t.isFixed){this.pinItem(t)}else{this.unPinItem(t)}this.emit("onPinClick",{item:t})}},{key:"pinItem",value:function e(t){var i=this.getPinnedItem(t.getId());if(!i){this.getPinnedItems().push(this.getPinnedItemFromItem(t))}ae.add(new W({item:this.getPinnedItem(t.getId()),anchor:this.fixedAnchor,startPosition:a.Dom.getPosition(t.getContainer())})).run();return this}},{key:"unPinItem",value:function e(t){var i=this.getPinnedItem(t.getId());if(i===t){var n=this.getItem(i.getId());if(n){n.isFixed=false;n.renderPin()}}if(i&&i.isRendered()){ae.add(new Z({node:i.getContainer()})).run()}this.pinnedItems=this.pinnedItems.filter((function(e){return e.getId()!==t.getId()}))}},{key:"onItemDelete",value:function e(t){this.deleteItem(t)}},{key:"deleteItem",value:function t(i){var n=e.getItemIndexFromArray(this.items,i.getId());var s=[];if(n!==null){if(i.isRendered()){var r=new Z({node:this.getItem(i.getId()).getContainer()});s.push(r)}this.items.splice(n,1)}n=e.getItemIndexFromArray(this.pinnedItems,i.getId());if(n!==null){if(i.isRendered()){var o=new Z({node:this.getPinnedItem(i.getId()).getContainer()});s.push(o)}this.pinnedItems.splice(n,1)}n=e.getItemIndexFromArray(this.tasks,i.getId());if(n!==null){var l=true;if(i.completedData){var u=this.createItem(i.completedData);if(u){if(!this.getItem(u.getId())){this.items.unshift(u);var d=this.constructor.getDayFromDate(u.getCreatedTime());if(d){if(!this.getDateSeparator(d)){var c=this.createDateSeparator(d);a.Dom.prepend(c,this.layout.itemsContainer)}ae.add(new Q({item:u,task:i,insertAfter:this.getDateSeparator(d)})).run();l=false}}}}if(l){s.push(new Z({node:this.getTask(i.getId()).getContainer()}))}this.tasks.splice(n,1)}ae.add(s).run()}},{key:"onError",value:function e(t){var i=t.message;this.showError(i)}},{key:"showError",value:function e(t){console.error(t)}},{key:"addUsers",value:function e(t){var i=this;if(a.Type.isPlainObject(t)){if(!this.users){this.users=new Map}Object.keys(t).forEach((function(e){e=a.Text.toInteger(e);if(e>0){i.users.set(e,t[e])}}))}}},{key:"addAnimation",value:function e(t){ae.add(t).run()}}],[{key:"getItemFromArray",value:function e(t,i){var n=null;var s=0;while(true){if(!t[s]){break}var a=t[s];if(a.getId()===i){n=a;break}s++}return n}},{key:"getItemIndexFromArray",value:function e(t,i){var n=null;var s=0;while(true){if(!t[s]){break}var a=t[s];if(a.getId()===i){n=s;break}s++}return n}},{key:"getDayFromDate",value:function t(i){if(i instanceof Date){if(e.isToday(i)){return BX.date.format("today")}return BX.date.format("d F Y",i)}return null}},{key:"isToday",value:function e(t){return BX.date.format("d F Y",t)===BX.date.format("d F Y")}}]);return e}();var ke={Stream:Te,Item:g,History:I,StageChange:D,Editor:H,CommentEditor:O,FieldsChange:L};e.Timeline=ke})(this.BX.UI=this.BX.UI||{},BX,BX.UI.Dialogs,BX.Main,BX.Event,BX);
//# sourceMappingURL=timeline.bundle.map.js